package com.bamboo.model.handler;

import com.bamboo.core.util.TimeUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
* @description 
* @date 2025/3/7 11:13
* @author chenzh
*/
@Component
public class FieldFillMetaHandler implements MetaObjectHandler {
    final Logger logger = LoggerFactory.getLogger(FieldFillMetaHandler.class);
    @Override
    public void insertFill(MetaObject metaObject) {
        logger.debug("start fill for insert...");
        this.strictInsertFill(metaObject, "createTime", Long.class, TimeUtil.nowSecond());
        this.strictInsertFill(metaObject, "updateTime", Long.class, TimeUtil.nowSecond());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        logger.debug("start fill for update...");
        this.strictInsertFill(metaObject, "updateTime", Long.class, TimeUtil.nowSecond());
    }
}
